﻿using gt.framework.Utils;
using gt.webapi.core.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace gt.webapi.core.sample2.Controllers
{
    [RoutePrefix("values")]
    public class ValuesController : ApiControllerBase
    {
        [Route("ok1"), HttpGet]
        public IHttpActionResult Ok(int id)
        {
            return Success<int>(id);
        }

        [AllowAnonymous]
        [Route("ok2"), HttpGet]
        public IHttpActionResult Ok2(int id)
        {
            return Success<int>(id);
        }

        [Route("error1"), HttpGet]
        public IHttpActionResult Error1(int id)
        {
            return Error(10, "error test");
        }
        [Route("error2"), HttpGet]
        public IHttpActionResult Error2(int id)
        {
            throw new Exception("this is test error!");
        }
    }
}
